<template>
	<view>
		<!-- #ifndef H5 -->
			<!-- <back></back> -->
		<!-- #endif -->
		<view class="fou_top u-flex u-row-between">
			<view class="u-flex">
				<image :src="info.avatar" mode="aspectFill"></image>
				<view>
					<view class="fou_tit">{{info.shopname}}</view>
					<view class="fou_peo">{{info.find_user.fans}}人关注</view>
				</view>
			</view>
			<view class="u-flex">
				<view class="fou_btn u-flex-center" @click="guan" v-if="info.isFollow == 0">
					<u-icon name="plus"></u-icon>关注
				</view>
				<view class="fou_btn u-flex-center" @click="guan" v-if="info.isFollow == 1">
					已关注
				</view>
			</view>
		</view>
		<mescroll-body :sticky="true" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<image :src="item" mode="aspectFill" class="bg" v-for="(item,index) in info.image" :key="index"></image>
			<u-waterfall style="padding: 25rpx 25rpx 0; display: flex;" v-model="flowList" ref="uWaterfall">
				<template v-slot:left="{leftList}">
					<view class="demo-warter" @click="$func.jump('/wNew/pages/detail?id=' + item.id)"
						v-for="(item, index) in leftList" :key="index">
						<!-- 警告：微信小程序中需要hx2.8.11版本才支持在template中结合其他组件，比如下方的lazy-load组件 -->
						<!-- <u-lazy-load threshold="-450" border-radius="10" :image=""
							:index="index"></u-lazy-load> -->
						<image :src="item.image" mode="widthFix" style="width: 300rpx;"></image>
						<view style="margin-top: 20rpx;line-height: 40rpx;">
							{{item.title}}
						</view>
						<view class="demo-tag">
							<view class="demo-tag-text" v-for="(it,key) in item.json">
								{{it}}
							</view>
						<!-- 	<view class="demo-tag-text demo-tag-text-grey">
								特产标签
							</view> -->
						</view>
						<view class="demo-price">
							<text>￥</text>{{item.price}}
							<text class="demo-price-grey">￥{{item.hx_price}}</text>
						</view>
						<view class="demo-shop" @click.stop="$func.jump('/wNew/pages/store?id=' + item.shop_id)">
							<!-- <image src="../../static/wImg/home.png"></image> -->
							<text class="mark" v-if="item.shop.isself == 1">平台</text>
							<text class="mark markOra" v-else>商家</text>
							<text class="mark markOra" v-if="item.platform_ms == 1">秒杀</text>
							<text class="mark markOra" v-if="item.platform_bk == 1">折扣</text>
							{{item.shop.shopname}}
							<u-icon name="arrow-right" color="#999"></u-icon>
						</view>
					</view>
				</template>
				<template v-slot:right="{rightList}">
					<view class="demo-warter" @click="$func.jump('/wNew/pages/detail?id=' + item.id)"
						v-for="(item, index) in rightList" :key="index">
						<!-- <u-lazy-load threshold="-450" border-radius="10" :image="item.image"
							:index="index"></u-lazy-load> -->
						<image :src="item.image" mode="widthFix" style="width: 300rpx;"></image>
						<view style="margin-top: 20rpx;line-height: 40rpx;">
							{{item.title}}
						</view>
						<view class="demo-tag">
							<view class="demo-tag-text"  v-for="(items,indexs) in item.json" :key="indexs">
								{{items}}
							</view>
							<!-- <view class="demo-tag-text demo-tag-text-grey">
								特产标签
							</view> -->
						</view>
						<view class="demo-price">
							<text>￥</text>{{item.price}}
							<text class="demo-price-grey">￥{{item.hx_price}}</text>
						</view>
						<view class="demo-shop" @click.stop="$func.jump('/wNew/pages/store?id=' + item.shop_id)">
							<!-- <image src="../../static/wImg/home.png"></image> -->
							<text class="mark" v-if="item.shop.isself == 1">平台</text>
							<text class="mark markOra" v-else>商家</text>
							<text class="mark markOra" v-if="item.platform_ms == 1">秒杀</text>
							<text class="mark markOra" v-if="item.platform_bk == 1">折扣</text>
							{{item.shop.shopname}}
							<u-icon name="arrow-right" color="#999"></u-icon>
						</view>
					</view>
				</template>
			</u-waterfall>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				flowList: [],
				id: '',
				info: {}
			}
		},
		onLoad(options) {
			this.id = options.id
			this.infoFn()
		},
		methods: {
			infoFn() {
				this.$u.post('/api/wanlshop/shop/getShopInfo', {
					id: this.id
				}).then(res => {
					if (res.code == 1) {
						this.info = res.data
					}
				});
			},
			guan() {
				this.$u.post('/api/wanlshop/find/user/setFindUser', {
					type: "follow",
					id: this.info.find_user.user_no
				}).then(res => {
					if (res.code == 1) {
						this.infoFn()
					} 
				});
			},
			upCallback(page) {
				// this.mescroll.optDown.use = false;
				this.mescroll.optUp.textNoMore = '- 已经到底啦 -'
				this.$u.post('/api/wanlshop/product/lists  ', {
					page: page.num,
					limit: page.size,
					search: '',
					sort: 'weigh',
					order: 'asc',
					filter:JSON.stringify({
						"shop_id": this.id,
					}),
					op: '{"shop_id": "in"}',
					location_city: uni.getStorageSync('city')
				}).then(res => {
					this.mescroll.endBySize(res.data.data.length, res.data.total);
					if (page.num == 1) this.flowList = []; //如果是第一页需手动制空列表
					this.flowList = this.flowList.concat(res.data.data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.fou_top {
		padding: 30rpx 60rpx 38rpx;
		background: #fff;

		image {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			margin-right: 18rpx;
		}

		.fou_tit {
			font-size: 28rpx;
			color: #333;
		}

		.fou_grey {
			font-size: 20rpx;
			color: #666;
			margin-top: 8rpx;
		}

		.fou_btn {
			width: 116rpx;
			height: 42rpx;
			font-size: 20rpx;
			color: #606DCE;
			z-index: 999;
			border-radius: 28rpx;
			border: 2rpx solid #606DCE;
		}
	}

	.bg {
		width: 92%;
		margin: 0 auto;
		height: 310rpx;
		border-radius: 20rpx;
		margin-top: 20rpx;
	}

	.demo-warter {
		border-radius: 8px;
		margin: 5px;
		background-color: #ffffff;
		padding: 8px;
		position: relative;
		max-width: 335rpx;
	}

	.demo-image {
		width: 100%;
		border-radius: 4px;
	}

	.demo-title {
		// font-size: 30rpx;
		// margin-top: 5px;
		// color: $u-main-color;
	}

	.demo-tag {
		display: flex;
		flex-wrap: wrap;
		margin-top: 5px;
		margin-left: -8rpx;
	}

	.demo-tag-owner {
		background-color: $u-type-error;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}

	.demo-tag-text {
		border: 1px solid #F43000;
		color: #F43000;
		line-height: 1;
		padding: 8rpx 24rpx 8rpx 16rpx;
		display: flex;
		align-items: center;
		border-radius: 4rpx;
		font-size: 20rpx;
		margin-bottom: 10rpx;
		margin-left: 8px;
	}

	.demo-tag-text-grey {
		border: 1px solid #999;
		color: #999;
	}

	.mark {
		font-size: 20rpx;
		color: #fff;
		padding: 4rpx 10rpx;
		background: #606DCE;
		border-radius: 4rpx;
		margin-right: 12rpx;
	}
	.markOra{
		background: #ef5205;
	}

	.demo-price {
		font-size: 30rpx;
		color: $u-type-error;
		margin-top: 5px;
		font-weight: bold;
		font-size: 32rpx;

		text {
			font-size: 20rpx;
		}

		.demo-price-grey {
			color: #D3D3D3;
			font-size: 20rpx;
			font-weight: 400;
			margin-left: 18rpx;
			text-decoration: line-through;
		}
	}

	.demo-shop {
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
		display: flex;
		flex-wrap: wrap;
		align-items: center;

		image {
			width: 20rpx;
			height: 20rpx;
			margin-right: 8rpx;
		}
	}
</style>